/**
 * Title :		Hyperbolic tree engine
 * Description: jFamilyTree Engine
 * Version:		1.10.x
 * Copyright:	(c) 2001-2005
 * Terms of use:see license agreement at http://treebolic.sourceforge.net/en/license.htm
 * Author:		Bernard Bou
 * Company:		bsys
 * Update:		15 juin 08
 */

package jFamilyTree.commons;

/**
 * DetermineCode base
 * 
 * @author Bernard Bou
 */
public class CodeBase
{
	/**
	 * Get code base
	 * 
	 * @return code base
	 */
	static public String getJarLocation()
	{
		String thisUrlString = Persist.class.getResource("CodeBase.class").toString(); //$NON-NLS-1$
		if (thisUrlString != null)
		{
			int thisIndex = thisUrlString.lastIndexOf("/jFamilyTree/commons/CodeBase.class"); //$NON-NLS-1$
			if (thisIndex != -1)
			{
				thisUrlString = thisUrlString.substring(0, thisIndex);
				if (thisUrlString.startsWith("jar:")) //$NON-NLS-1$
				{
					int thisIndex2 = thisUrlString.lastIndexOf('/');
					thisUrlString = thisUrlString.substring(4, thisIndex2);
					return thisUrlString;
				}
			}
		}
		return null;
	}
}
